package com.loong.common.executor;

import com.loong.common.function.CommonExecutor;
import com.loong.common.function.CommonSupplier;
import com.loong.common.rest.Result;
import org.springframework.stereotype.Component;

@Component
public class HandlerExecutor {

    public Result execute(CommonExecutor executor){
        executor.execute();
        return Result.success().build();
    }
    public Result execute(CommonExecutor executor,String message){
        executor.execute();
        return Result.success().message(message).build();
    }

    public Result execute(CommonSupplier executor, String message){
        return Result.success().data(executor.get()).message(message).build();
    }
    public Result execute(CommonSupplier executor){
        return Result.success().data(executor.get()).build();
    }
}
